<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="com.user" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>编辑页面</title>
    <link rel="stylesheet" href="css/bookstrap.css">

    <script src="js/jquery.min.js"></script>
    <script src="js/bookstrap.js"></script>
    <script src="js/bookstrap.bundle.js"></script>

    <style>
        .container {
            width: 50%;
            margin-top: 20px;
        }
        </style>
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
    <h3 style="text-align: center">编辑页面</h3>
    <form method="post" action="update.jsp">

 <%
     int id=Integer.parseInt(request.getParameter("id"));

     Class.forName("com.mysql.jdbc.Driver");

     String url="jdbc:mysql://localhost:3306/book";

     Connection connection = DriverManager.getConnection(url,"root","root");

     String sql ="select * from user where id = ?";

     PreparedStatement ps=connection.prepareStatement(sql);

     ps.setInt(1,id);

     ResultSet rs = ps.executeQuery();
     while (rs.next()){
         out.print("<input type='hidden' name='id' value="+rs.getString("id")+">");
         out.print("用户名：<input type='text'class='form-control' name='username' value="+rs.getString("username")+">");
         out.print("密码：<input type='text'class='form-control' name='password' value="+rs.getString("password")+">");

         out.print("性别：<input type='text'class='form-control' name='gender' value="+rs.getString("gender")+">");
         out.print("年龄：<input type='text'class='form-control' name='age' value="+rs.getString("age")+">");

     }
 %>
        <button type="submit" style="width: 100%" class="btn btn-info">提交</button>

    </form>
        </div>
    </div>
</div>
</body>
</html>